#include<bits/stdc++.h>
using namespace std;

int main(){
    freopen("detect.in" , "r" , stdin);
    freopen("detect.out" , "w" , stdout);

    int t , n , m ;
    long long L , V;
    cin >> t;

    for(int k = 0 ; k < t ; k ++){
        cin >> n >> m >> L >> V;
        long long d[n + 1] , v[n + 1] , a[n + 1];
        long long p[m + 1];
        bool saven[m + 1] = {0};
        for(int i = 1 ; i <= n ; i ++){
            cin >> d[i] >> v[i] >> a[i];
        }
        for(int i = 1 ; i <= m ; i ++){
            cin >> p[i];
        }

        int sum = 0;
        V = V * V;
        for(int i = 1 ; i <= n ; i ++){
            v[i] *= v[i];
            a[i] *= 2;
            bool flag = 0;
            double s = double(V - v[i]) / double(a[i]);
            if(s <= 0)continue;
            if(a[i] >= 0){
                for(int j = 1 ; j <= m ; j ++){
                    if(p[j] < d[i])continue;
                    double sp = double(p[j] - d[i]);
                    sp *= sp;
                    if(sp < s)continue;
                    saven[j] = 1;flag = 1;break;
                }
                if(flag)sum ++;
            }else{
                for(int j = 1 ; j <= m ; j ++){
                    if(p[j] < d[i])continue;
                    double sp = p[j] - d[i];
                    sp *= sp;
                    if(sp <= s){saven[j] = 1;flag = 1;break;}
                }
                if(flag)sum ++;
            }
        }

        cout << sum << " ";
        sum = 0;
        for(int i = 1 ; i <= m ; i ++){
            if(saven[i] == 0){
                sum ++;
            }
        }
        cout << sum << endl;
    }

    return 0;
}
